<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DEMO</title>

</head>

<body>
    <div id="editor"></div>
    <script src="./js/tinymce.min.js"></script>
    <script>
        tinymce.init({
            selector: '#editor',
            language: 'zh_CN',
            menubar: 'file edit insert view format table tools help custom1',
            menu: {
                custom1: { title: '标题', items: 'copy' }
            },
            plugins: 'preview fullscreen image link media code hr pagebreak imagetools autoresize',
            toolbar: [
                'undo redo | cut copy paste | forecolor backcolor bold italic underline strikethrough link | alignleft aligncenter alignright alignjustify outdent indent | blockquote subscript superscript removeformat',
                'styleselect formatselect fontselect fontsizeselect |image media hr pagebreak preview fullscreen | lineheight code | customInsertButton customDateButton'
            ],
            min_height: 400, // autoresize属性
            max_height: 800, // autoresize属性
            width: 1000,
            resize: 'both',
            fontsize_formats: '12px 14px 16px 18px 24px 36px 48px 56px 72px',
            font_formats: '微软雅黑=Microsoft YaHei,Helvetica Neue,PingFang SC,sans-serif;苹果苹方=PingFang SC,Microsoft YaHei,sans-serif;宋体=simsun,serif;仿宋体=FangSong,serif;黑体=SimHei,sans-serif;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;',
            link_list: [ // link预置链接
                { title: '预置官方链接', value: 'http://www.tinymce.com' },
                { title: '预置中文链接', value: 'http://tinymce.ax-z.cn' }
            ],
            // 自定义上传图片
            images_upload_handler: (blobInfo, success, failure) => {
                let formdata = new FormData();
                formdata.append("imgData", blobInfo.base64());
                formdata.append("name", blobInfo.blob().name);
                formdata.append("size", blobInfo.blob().size);
                formdata.append("type", blobInfo.blob().type);
                console.log(blobInfo.blob());
                success('https://www.baidu.com/img/bd_logo1.png');
                // this.$api.uploadImage(formdata).then(res => {
                //     success(res.info.path);
                // });
            },
            file_picker_callback: function (callback, value, meta) {
                if (meta.filetype === 'file') {
                    callback('https://www.baidu.com/img/bd_logo1.png', { text: 'My text' });
                }
                if (meta.filetype === 'image') {
                    callback('https://www.baidu.com/img/bd_logo1.png', { alt: 'My alt text' });
                }
                if (meta.filetype === 'media') {
                    callback('movie.mp4', { source2: 'alt.ogg', poster: 'https://www.baidu.com/img/bd_logo1.png' });
                }
            },
            setup: function (editor) {
                editor.ui.registry.addButton('customInsertButton', {
                    text: '自定义按钮',
                    onAction: function () {
                        editor.insertContent('自定义按钮');
                    }
                });
            },
        });
    </script>

</body>

</html>